import java.util.LinkedList;

public class BibliotecaApp {

    Menu menu= new Menu();
    Library library = new Library();
    private LinkedList<Command> commandLinkedList;

    public BibliotecaApp(){
        commandLinkedList = new LinkedList<Command>();
        commandLinkedList.add(null);
        commandLinkedList.add(new ViewBooksCommand(library,menu));
        commandLinkedList.add(new ReserveBookCommand(library,menu));
        commandLinkedList.add(new CheckMembershipCommand(library,menu));
        commandLinkedList.add(new ViewMoviesCommand(library,menu));
        commandLinkedList.add(new LoginCommand(library,menu));
        commandLinkedList.add(new QuitCommand(library,menu));
    }

    public static void main(String[] args) {
        BibliotecaApp app = new BibliotecaApp();
        app.defaultSetup();
        app.menu.welcomeMessage();
        while(true){
            app.menu.printMenuOptions();
            int instructionInteger = app.menu.selectMenuOption();
            app.actionPerformed(instructionInteger);
        }

    }

    public void actionPerformed(int instructionInteger){
        commandLinkedList.get(instructionInteger).run();
    }

    public void defaultSetup(){
        this.library.addBook(new Book("GoldFish"));
        this.library.addBook(new Book("Run"));
        this.library.addMovie(new Movie("The Hobbit", "2012", "Peter Jackson", "10"));
        this.library.addMovie(new Movie("Pans Labrynth", "2010", "Sophie Krisch", "9"));
        this.library.addMovie(new Movie("Harry Potter", "2007", "Stacey Watro", "8"));
        this.library.addMovie(new Movie("Casablanca", "1939", "Humphrey Bogart", "10"));
        this.library.addMovie(new Movie("Up", "2011", "Old Man", "9"));
        this.library.addMovie(new Movie("Clue", "1975", "Professor Plum", "2"));
        this.library.addMovie(new Movie("Snake on a Plane", "2006", "Samuel L. Jackson", "1"));
        this.library.addMovie(new Movie("Superman", "1960", "Christopher Reeve", "N/A"));
        this.library.addMovie(new Movie("Into the Wild", "2009", "Sophie Krisch", "8"));
        this.library.addMovie(new Movie("Pitch Perfect", "2012", "Fat Amy", "7"));
        this.library.addMovie(new Movie("Zero Dark Thirty", "2012", "Jessica Chastain", "9"));
        this.library.addMovie(new Movie("Argo", "2012", "Ben Afflec", "8"));
        this.library.addMovie(new Movie("Sleeping Beauty", "1960", "The Prince", "5"));
        this.library.addMovie(new Movie("Snow White", "1950", "Grumpy", "7"));
        this.library.addMovie(new Movie("The Lion King", "1985", "Mufasa", "10"));
    }

}
